﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ResourceManager {

	private static ResourceManager _instance;

	private Dictionary<string, Object> resourceDic = new Dictionary<string, Object>();

	private ResourceManager() {
	}

	public static ResourceManager Instance {
		get {
			if (_instance == null) {
				_instance = new ResourceManager ();
			}
			return _instance;
		}
	}

	public void Init() {
		// read config file and load all prefabs
		AddResource("Prefab/player");
	}

	private void AddResource(string path) {
		Object o;

		if (Platform.LoadResource (path, out o)) {
			resourceDic [path] = o;
		} else {
			Debug.LogWarning (string.Format("Load resource {0} failed!", path));
		}
	}

	public Object GetResource(string key) {
		return resourceDic [key];
	}
}
